<?php
		require_once("database.php");
		
	 function mg_select($database,$tmp_sql)
	{
			$result = mysql_query($tmp_sql, $database);
			
			if (!$result) {
			    echo "DB Error, could not query the database\n";
			    echo 'MySQL Error: ' . mysql_error();
			    return;
			}
			$resultSet = array();
			while ($row = mysql_fetch_assoc($result)) {
				$resultSet[] = $row;
			}		
			mysql_free_result($result);
			return $resultSet;
	}
	
function mg_insert($database,$tmp_sql)
	{
			$result = mysql_query($tmp_sql, $database);
			
			if (!$result) {
			    echo "DB Error, could not query the database\n";
			    echo 'MySQL Error: ' . mysql_error();
			    exit;
			}		
			mysql_free_result($result);	
			return;	
	}	
		
		//$database = new database("61.160.251.28",3306,"root","5318422","wedok");
		if (!$database =  mysql_connect("61.160.251.28","wedok","5318422")) {
		//if (!$database =  mysql_connect("localhost","wedok","5318422")) {
		    echo 'Could not connect to mysql';
		     $file = fopen("log","a");
                          fwrite($file,"\r\n fdsafa Could not connect to mysql",true);
            fclose($file);		
		    exit;
		}
		
		if (!mysql_select_db('wedok', $database)) {
		    echo 'Could not select database';
		     $file = fopen("log","a");
                          fwrite($file,"\r\n fdsafa select database",true);
            fclose($file);			    
		    exit;
		}
$username = $_POST['userName'];
$sess = $_POST['sess'];
$sql = 'update fo_zpic_users set user_money = user_money + 500 where username = "'.$username.'" and user_website="'.$sess.'"';

		mg_insert($database,$sql);		
echo "ok";

?>